package graphics.ParticleSystem;




public class VolcanoParticleSystem extends AbstractParticleSystem{
	float diameter = 1f;
	float spread = 0.3f;
	float speed = 0.2f;

	public VolcanoParticleSystem(){
		setMax_points(500);
		setDecay_rate(0.05f);
		setNew_points(10);
	}
	
	@Override
	protected float[] createPoint() {
		 float x = (random.nextFloat()-0.5f)*diameter;
		 float y = 0;
		 float z = (random.nextFloat()-0.5f)*diameter;
		 float sy = random.nextFloat() * speed;
		 float sx = (random.nextFloat()-0.5f)*spread*sy;
		 float sz = (random.nextFloat()-0.5f)*spread*sy;
		 
		 return new float[] {
				 x,y,z,
				 sx,sy,sz,
				 1,0,0,
				 1};
	}

	@Override
	protected void updateColor(int i) {
		colors_arr[i*3+1] += decay_rate;
	}


	public float getDiameter() {
		return diameter;
	}

	public void setDiameter(float diameter) {
		this.diameter = diameter;
	}

	public float getSpread() {
		return spread;
	}

	public void setSpread(float spread) {
		this.spread = spread;
	}

	public float getSpeed() {
		return speed;
	}

	public void setSpeed(float speed) {
		this.speed = speed;
	}

	@Override
	public void setParameter(String name, String[] params) {
		if (name.equals("spread")) {
			setSpread(Float.parseFloat(params[0]));
		}
		if (name.equals("diameter")) {
			setDiameter(Float.parseFloat(params[0]));
		}
		if (name.equals("speed")) {
			setSpeed(Float.parseFloat(params[0]));
		}
		super.setParameter(name, params);
	}
	
	
	
}
